﻿Imports System.ComponentModel
Imports System.IO
Imports System.Windows.Forms

Public Class IniForm
    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
        Dim fol As New FolderBrowserDialog
        fol.Description = "选择代码库锁在路径：" & vbCrLf & "代码库最多支持2级文件夹！"
        If fol.ShowDialog = Windows.Forms.DialogResult.OK Then  '如果选择了文件夹
            TextBox1.Text = fol.SelectedPath & "\"  '显示选着文件夹路径
        Else
            TextBox1.Text = ""
        End If
    End Sub



    Private Sub IniForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        CheckBox1.Checked = Val(ReadOneString("配置信息", "是否顶级缩进", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\配置.ini"))
        CheckBox2.Checked = IIf(IO.File.Exists(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\配置.ini") = True, Val(ReadOneString("配置信息", "是否智能缩进", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\配置.ini")), 1) '控制智能提示开关
        Dim PP As String = ReadOneString("配置信息", "代码库路径", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\配置.ini")

        TextBox1.Text = IIf(PP = "", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\Code\", PP)
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If IO.Directory.Exists(TextBox1.Text) = False Then
            MsgBox("找不到代码库路径，请重新选定后重试！")
        End If

        WriteOneString("配置信息", "是否顶级缩进", IIf(CheckBox1.Checked = True, 1, 0), Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\配置.ini")
        WriteOneString("配置信息", "是否智能缩进", IIf(CheckBox2.Checked = True, 1, 0), Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\配置.ini")
        KeyTip_TN = IIf(CheckBox2.Checked = True, 1, 0)

        WriteOneString("配置信息", "代码库路径", TextBox1.Text, Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) & "\配置.ini")
        MsgBox("更新完成！" & vbCrLf & "若修改代码库路径，需重启程序生效！")
    End Sub
End Class